home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 4 / BBS in a Box - Macintosh - Volume IV (January 1992) (BBS in a Box).iso / Files / Prog / D-G / EASY.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-05-25  |  7.4 KB  |  174 lines  |  [TEXT/MACA]

  1.     terse        specify abbreviated listing format
  2. ;****************************************************************
  3.  
  4. ; Copyright (c) 1987 by Grand Canyon Code Factory
  5. ; No rights reserved
  6.  
  7. ; This is a simple application that you can easily customize.
  8. ; It writes your name in a note alert.  It is mostly to familiarize you
  9. ; with using an assembler.  You will need the shareware assembler
  10. ; McAssembly as well as the .PSM files available from this SIG. You
  11. ; should also have EDIT from Apple, also available from AMUG. McAssembly
  12. ; works best with EDIT if you rename McAssembly "ASM" on your working
  13. ; disk.
  14.  
  15. ; This file includes both Easy.asm and Easy.job.  If you look at
  16. ; the end of this file you will see that there are two lines that you
  17. ; are asked to cut and paste into a separate text file called Easy.job.
  18. ; You can also find a place where you are asked to replace the name
  19. ; "John Doe" with your own name.  If your name happens to be John Doe,
  20. ; you don't have to make this change.  You will also find an "ipath"
  21. ; pseudo-op below ( a pseudo-op is a message to the assembler that doesn't
  22. ; actually generate machine language ).  There are instructions at the
  23. ; ipath for setting it up to match your disk. You can even use more than
  24. ; one ipath if for some strange reason you want to put your include files
  25. ; in different folders.
  26.  
  27. ; Once you have replaced John Doe with your own name, fixed the ipath,
  28. ; and saved Easy.job you can transfer directly to McAssembly by choosing
  29. ; ASM from EDIT's transfer menu. Don't worry if it says something like
  30. ; "ASM Easy.asm."  When you get into McAssembly choose "Run job" from
  31. ; the file menu if all goes well you should see a bunch of messages about
  32. ; the assembly and and the link, ending with a "Job is Done" message.
  33. ; If the message above that is "OK - no errors in the link" you can
  34. ; be fairly sure that all has gone well. You can quit to the finder and
  35. ; see your new application or just transfer to easy from using McAssembly's
  36. ; transfer menu and run it.
  37.  
  38. ; When you do get back to the desktop you'll see a file named Easy.rel
  39. ; along with your new application named Easy.  If you don't know what
  40. ; .rel files are all about don't worry, you can throw it away. We we
  41. ; eventually cover .rel files, explaining why the assembler makes them
  42. ; and what the're good for. For you 'C' and Pascal folks, let me pique
  43. ; your curiosity by saying that when your manual talks about "linking
  44. ; to assembly language, remember that the .rel file is what your compiler
  45. ; needs to do the link.
  46.  
  47. ; When you get bored with your new program, come back and read this file.
  48. ; The comments have some usefull information.
  49.  
  50. ; This program has been placed in the public domain by Grand Canyon
  51. ; Code Factory. You may use it, modify it, or change it in any way you
  52. ; see fit.
  53.  
  54. ;****************************************************************
  55.  
  56.     title    "Hello World   $"    title for listing with timestamp
  57.  
  58. ;****************************************************************
  59. ; If you haven't figured it out by now, anything that comes after a ";"
  60. ; is a comment.  In assembler a separator is one or more tabs or spaces.
  61. ; The syntax of an assembly language line is LABEL in column one,
  62. ; then a separator then the OPCODE, another separator, the ADDRESS,
  63. ; another separator then a comment.  If you want to have a line with only
  64. ; a comment, you have to start with the ";".  You can include blank lines
  65. ; wherever you want for readability.
  66. ;****************************************************************
  67.  
  68. ;Configure our application file:
  69.  
  70.     ftype    'APPL'        file type
  71.     fsign    'GCCF'        file creator signature
  72.     a5off    $100        Color QuickDraw, you pig!
  73.  
  74. ;****************************************************************
  75. ;Include trap definitions & equate files:
  76.  
  77. ; The ipath assumes you have an HFS disk called 'Assembler' which
  78. ; contains a folder named 'Include files' which contains all
  79. ; of these includes. If you have a different setup, then you'll
  80. ; have to change ipath accordingly.
  81.  
  82.     ipath    "Assembler:Include files:"    folder with includes
  83.  
  84.     Incl    "SysEqu.psm"        system equates
  85.     incl    "QuickEqu.PSM"        quick draw equates
  86.     incl    "ToolEqu.PSM"        toolbox equates
  87.     incl    "RegisterTraps.PSM"    register-based trap words
  88.     incl    "SysErr.PSM"        system error code equates
  89.     incl    "FSEqu.PSM"        file system equates
  90.     incl    "PackMacs.PSM"        package equates
  91.     incl    "Symbol.PSM"        my own stuff
  92.  
  93. ; I use an "everything including the kitchen sink" approach when it
  94. ; comes to includes. That way I can refer to everything documented in
  95. ; Inside Mac by name.  This approach works fine unless you're trying
  96. ; to assemble in 128K.  If anyone is and this won't assemble, leave me a
  97. ; message.
  98.  
  99. ;****************************************************************
  100.  
  101.     tcomp        tcomp is magic! It tells the assembler that even
  102. ;            though we're assembling and not compiling when we
  103. ;            call ROM we want to use "Pascal style."   This saves
  104. ;            rummaging about in IM for the assembler forms of
  105. ;            ROM calls.  In fact, once we say tcomp we can use
  106. ;            either form. It only works for stack based traps
  107. ;            though.
  108.  
  109. ;****************************************************************
  110. ; This is our variable storage area off of A5.  Don't worry if this
  111. ; doesn't make sense yet.  I'll try to explain all this in the hardware
  112. ; write up.  For now just understand that this tells the mac to save
  113. ; two bytes of space for TheItem in it's global variable area.  If you
  114. ; can't wait to understand this, Chapter 3 the in first volume of
  115. ; Chernicoff explains it very well.
  116.  
  117.     A5sec
  118. TheItem    integer
  119.     A5end
  120.  
  121. ;****************************************************************
  122. ; Start up by initializing the managers.  Every stand-alone program
  123. ; should start just this way.
  124.     
  125. Start    InitGraf    !-4(a5)        init QuickDraw with space for its use
  126.     InitFonts            init Font Manager
  127.     InitWindows            init Window Manager
  128.     InitMenus            init Menu Manager
  129.     InitDialogs    #Nil        init Dialog Manager (no restart proc)
  130.  
  131. ; Note the # sign in front of Nil. In assembly language we always
  132. ; have to tell the assembler if someting is a number. Otherwise,
  133. ; the assembler will assume it's an address.
  134.  
  135.     TEInit                 init Text Edit
  136.  
  137. ; FlushEvents is register based, not really part of the toolbox event
  138. ; manager but rather of the down and dirty OS event manager. Therefore,
  139. ; there is no fancy trap compiler form for FlushEvents. We have to do this
  140. ; hacker style, cram a long in a register and inline a trap.
  141.  
  142.     MOVE.L    #$0000FFFF,D0        no stop in high word, everyevent in low word
  143.     _FlushEvents            flush all pending events
  144.     InitCursor            init cursor to arrow
  145.     NoteAlert    #1001,#Nil,TheItem
  146.     RTS        We can bail out this way because the segment loader
  147. ;            politely left Finders address on the stack.
  148.  
  149. ; The rest of this isn't code at all.  This is for McAssembly's
  150. ; resource compiler.  This all could have been done with ResEdit.
  151.  
  152. $$ALRT,1001,%00100000,Hello Alert    an alert named Hello Alert
  153. ; The %00100000 sets the attribute byte.  We could have used hex but binary
  154. ; is more WYSIWYG.
  155. 90,100,240,400                top, left, bottom, right
  156. 1001                    item list ID
  157. %0101010101010101            stages
  158.  
  159. $$DITL,1001,%00100000,Hello Item List    the item list for Hello Alert
  160. 2                    two items
  161.  
  162. 0                    place holder for handle
  163. 115,110,140,140                top, left, bottom, right
  164. ctrlItem+btnCtrl,OK            the OK button
  165.  
  166. 0                    place holder for handle
  167. 80,5,100,280                top,left,bottom, right
  168. ; type your own name instead of John Doe on the next line
  169. statText+itemDisable,Hello World!  I'm John Doe
  170.  
  171.     end
  172. ; cut the next two lines and save them in the separate file Easy.job.
  173. Easy
  174. /Easy